@Api(value = "模块名", description = "background/模块名")
@RestController
@RequestMapping(value = "/background/dmap-knowledge-server/v1/article")
public class PageOperateBackController {
    @Resource
    private PageOperateService pageOperateService;
    @ResponseBody
    @ApiOperation(value = "新增模块名", notes = "新增模块名")
    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    public BaseVo insertPageOperate(@RequestBody PageOperateParam param) {
        BaseVo result = new BaseVo();
        if ( param.getPageId() == 0 || StringUtils.isBlank(param.getWebUrl())|| StringUtils.isBlank(param.getRequestUrl())|| StringUtils.isBlank(param.getPageOperateCode())|| StringUtils.isBlank(param.getPageOperateName())|| StringUtils.isBlank(param.getDescription())|| param.getOperateType() == 0 || param.getIsFieldOperate() == 0 || param.getRequestType() == 0 || StringUtils.isBlank(param.getIconUrl())|| param.getCreateTime() == 0 || param.getUpdateTime() == 0    ){            result.setCode(Constant.RESPONSE_PARAM_ERROR_CODE);
            result.setMsg(Constant.RESPONSE_PARAM_ERROR_MSG);
            return result;
        }
        //进行字符串的数字验证
        int success = pageOperateService.insertPageOperate(param);
       if (success == 0) {
           result.setCode(Constant.RESPONSE_INSERT_ERROR_CODE);
           result.setMsg(Constant.RESPONSE_INSERT_ERROR_MSG);
        }
        return result;
    }
    @ResponseBody
   @ApiOperation(value = "修改模块名", notes = "修改模块名")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
   public BaseVo updatePageOperate(@RequestBody PageOperateEditParam  param) {
       BaseVo result = new BaseVo();
        if (StringUtils.isBlank(param.getPageOperateId()) || StringUtils.isNumeric(param.getPageOperateId())|| param.getPageId() == 0 || StringUtils.isBlank(param.getWebUrl())||
 StringUtils.isBlank(param.getRequestUrl())||
 StringUtils.isBlank(param.getPageOperateCode())||
 StringUtils.isBlank(param.getPageOperateName())||
 StringUtils.isBlank(param.getDescription())||
 param.getOperateType() == 0 || param.getIsFieldOperate() == 0 || param.getRequestType() == 0 || StringUtils.isBlank(param.getIconUrl())||
 param.getCreateTime() == 0 || param.getUpdateTime() == 0    ){
            result.setCode(Constant.RESPONSE_PARAM_ERROR_CODE);
            result.setMsg(Constant.RESPONSE_PARAM_ERROR_MSG);
            return result;
        }
        //进行字符串的数字验证
        int success = pageOperateService.updatePageOperate(param);
        if (success == 0) {
            result.setCode(Constant.RESPONSE_UPDATE_ERROR_CODE);
            result.setMsg(Constant.RESPONSE_UPDATE_ERROR_MSG);
        }
        return result;
    }
    @Transactional
    @ResponseBody
    @ApiOperation(value = "删除模块名", notes = "删除模块名")
    @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
    public BaseVo deletePageOperate(@RequestParam String pageOperateIds) {
       BaseVo result = new BaseVo();
        if (StringUtils.isBlank(pageOperateIds)) {
           result.setCode(Constant.RESPONSE_PARAM_ERROR_CODE);
           result.setMsg(Constant.RESPONSE_PARAM_ERROR_MSG);
           return result;
        }
        int success = pageOperateService.deletePageOperateList(pageOperateIds);
       if (success == 0) {
           result.setCode(Constant.RESPONSE_DELETE_ERROR_CODE);
           result.setMsg(Constant.RESPONSE_DELETE_ERROR_MSG);
       }
        return result;
    }
    @ResponseBody
   @ApiOperation(value = "查询模块名", notes = "查询模块名")
    @RequestMapping(value = "/select", method = RequestMethod.GET)
   public BaseVo selectPageOperate(@RequestParam(required = false) String companyNumber,
                                @RequestParam(required = false) String appNumber,
                                @RequestParam String lang,
                               @RequestParam(required = false) String key,
                              @RequestParam(required = false, defaultValue = "0") long order,
                                @RequestParam int pageIndex,
                                @RequestParam int pageSize) {
        BaseVo result = new BaseVo();
        if (StringUtils.isBlank(lang) || pageIndex == 0 || pageSize == 0) {
           result.setCode(Constant.RESPONSE_PARAM_ERROR_CODE);
           result.setMsg(Constant.RESPONSE_PARAM_ERROR_MSG);
           return result;
        }
        if (appNumber != null && StringUtils.isBlank(appNumber)) {
            result.setCode(Constant.RESPONSE_PARAM_ERROR_CODE);
            result.setMsg(Constant.RESPONSE_PARAM_ERROR_MSG);
            return result;
        }
        if (companyNumber != null && StringUtils.isBlank(companyNumber)) {
            result.setCode(Constant.RESPONSE_PARAM_ERROR_CODE);
            result.setMsg(Constant.RESPONSE_PARAM_ERROR_MSG);
            return result;
        }
        PageOperateBackVo pageOperateBackVo = new PageOperateBackVo();
        List<PageOperateSelectVo> pageOperateSelectVoList = new ArrayList<>();
        PageOperateSelectParam pageOperateSelectParam = new PageOperateSelectParam();
        List<PageOperate> pageOperateList = pageOperateService.selectPageOperate(pageOperateSelectParam);
        pageOperateList.forEach(pageOperate->pageOperateSelectVoList.add(new PageOperateSelectVo(pageOperate)));
        pageOperateBackVo.setPageOperateList(pageOperateSelectVoList);
        pageOperateBackVo.setCount(pageOperateService.countPageOperate(pageOperateSelectParam));
        result.setData(pageOperateBackVo);
        return result;
    }
    @ResponseBody
    @ApiOperation(value = "查看模块名信息", notes = "查看模块名信息")
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    public BaseVo selectPageOperate(@RequestParam String pageOperateId) {
        BaseVo result = new BaseVo();
       if (StringUtils.isBlank(pageOperateId) || !StringUtils.isNumeric(pageOperateId)) {
            result.setCode(Constant.RESPONSE_PARAM_ERROR_CODE);
            result.setMsg(Constant.RESPONSE_PARAM_ERROR_MSG);
            return result;
        }
        PageOperate   pageOperate = pageOperateService.getPageOperate(Long.parseLong(pageOperateId));
       //自定义不存在错误
        if (pageOperate == null) {
           result.setCode(111);
            result.setMsg("自定义不存在错误");
            return result;
        }
        PageOperateInfoVo pageOperateInfoVo = new PageOperateInfoVo(pageOperate);
        result.setData(pageOperateInfoVo);
        return result;
   }
}
